home *** CD-ROM | disk | FTP | other *** search
/ Freaks Macintosh Archive / Freaks Macintosh Archive.bin / Freaks Macintosh Archives / Textfiles / zines / Phrack / Phrack Issue 53.sit / 53 / P53-08 < prev    next >
Text File  |  1998-07-08  |  22KB  |  725 lines

  1. ---[  Phrack Magazine   Volume 8, Issue 53 July 8, 1998, article 08 of 15
  2.  
  3.  
  4. -------------------------[  Linux Trusted Path Execution Redux
  5.  
  6.  
  7. --------[  Krzysztof G. Baranowski  <kgb@manjak.knm.org.pl>
  8.  
  9.  
  10.  
  11. ---[  Introduction
  12.  
  13.  
  14. The idea of trusted path execution is good, however the implementation which
  15. appeared in Phrack 52-06 may be a major annoyance even to the root itself, eg.
  16. old good INN newsserver keeps most of its control scripts in directories owned
  17. by news, so it would be not possible to run them, when the original TPE patch
  18. was applied.  The better solution would be to have some kind of access list
  19. where one could add and delete users allowed to run programs.  This can be
  20. very easily achieved, all you have to do is to write a kernel device driver,
  21. which would allow you to control the access list from userspace by using
  22. ioctl() syscalls.
  23.  
  24.  
  25. ---[  Implementation
  26.  
  27.  
  28. The whole implementation consists of a kernel patch and an userspace program.
  29. The patch adds a new driver to the kernel source tree and performs a few minor
  30. modifications.  The driver registers itself as a character device called "tpe",
  31. with a major number of 40, so in /dev you must create a char device "tpe" with 
  32. major number of 40 and a minor number of 0 (mknod /dev/tpe c 40 0).  The most
  33. important parts of the driver are:
  34.  
  35.         a)  access list of non-root users allowed to run arbitrary programs
  36.             (empty by default, MAX_USERS can be increased in
  37.             include/linux/tpe.h),
  38.  
  39.     b)  tpe_verify() function, which checks whether a user should be
  40.             allowed to run the program and optionally logs TPE violation
  41.             attempts.  The check if should we use tpe_verify() is done before 
  42.             the program will be executed in fs/exec.c.  If user is not root 
  43.             we perform two checks and allow execution only in two cases:
  44.  
  45.         1) if the directory is owned by root and is not group or
  46.                    world writable (this check covers binaries located
  47.                    in /bin, /usr/bin, /usr/local/bin/, etc...).
  48.  
  49.         2) If the above check fails, we allow to run the program
  50.                    only if the user is on our access list, and the program
  51.                    is located in a directory owned by that user, which
  52.                    is not group or world writable.
  53.  
  54.         All other binaries are considered untrusted and will not be allowed
  55.             to run. The logging of TPE violation attempts is a sysctl option
  56.             (disabled by default).  You can control it via /proc filesystem:
  57.             echo 1 > /proc/sys/kernel/tpe
  58.             will enable the logging:
  59.             echo 0 > /proc/sys/kernel/tpe
  60.             will turn it off.  All these messages are logged at KERN_ALERT
  61.             priority.
  62.  
  63.     c)  tpe_ioctl() function, is our gate to/from the userspace.  The
  64.             driver supports three ioctls:
  65.  
  66.         1) TPE_SCSETENT - add UID to the access list,
  67.         2) TPE_SCDELENT - delete UID from the access list,
  68.                3) TPE_SCGETENT - get entry from the access list.
  69.  
  70.             Only root is allowed to perform these ioctl()s.
  71.  
  72. The userspace program called "tpadm" is very simple.  It opens /dev/tpe and
  73. performs an ioctl() with arguments as given by user.
  74.  
  75.  
  76. ---[  In Conclusion
  77.  
  78.  
  79. Well, that's all.  Except for the legal blurb [1]:
  80.  
  81. "As usual, there are two main things to consider:
  82.     1. You get what you pay for.
  83.     2. It is free.
  84.     
  85. The consequences are that I won't guarantee the correctness of this document,
  86. and if you come to me complaining about how you screwed up your system because
  87. of wrong documentation, I won't feel sorry for you.  I might even laugh at you.
  88.  
  89. But of course, if you _do_ manage to screw up your system using this I'd like
  90. to hear of it.  Not only to have a great laugh, but also to make sure that
  91. you're the last RTFMing person to screw up.
  92.  
  93. In short, e-mail your suggestions, corrections and / or horror stories to
  94. <kgb@manjak.knm.org.pl>."
  95.  
  96. Krzysztof G. Baranowski - President of the Harmless Manyacs' Club
  97. http://www.knm.org.pl/                 <prezes@manjak.knm.org.pl>
  98. --
  99. [1] My favorite one, taken from Linux kernel Documentation/sysctl/README,
  100.     written by Rik van Riel <H.H.vanRiel@fys.ruu.nl>.
  101.  
  102.  
  103. ----[  The code
  104.  
  105. <++> EX/tpe-0.02/Makefile
  106. #
  107. # Makefile for the Linux TPE Suite.
  108. # Copyright (C) 1998 Krzysztof G. Baranowski. All rights reserved.
  109. #
  110. # Change this to suit your requirements
  111. CC        = gcc
  112. CFLAGS      = -Wall -Wstrict-prototypes -g -O2 -fomit-frame-pointer \
  113.             -pipe -m386
  114.  
  115. all: tpadm patch 
  116.  
  117. tpadm: tpadm.c
  118.     $(CC) $(CFLAGS) -o tpadm tpadm.c
  119.     @strip tpadm
  120.  
  121. patch:
  122.     @echo
  123.     @echo    "You must patch, reconfigure, recompile your kernel"
  124.     @echo    "and create /dev/tpe (character, major 40, minor 0)"
  125.     @echo
  126.  
  127. clean:
  128.      rm -f *.o core tpadm
  129. <-->
  130. <++> EX/tpe-0.02/tpeadm.c
  131. /*
  132.  *     tpe.c - tpe administrator
  133.  *
  134.  *     Copyright (C) 1998 Krzysztof G. Baranowski. All rights reserved.
  135.  *
  136.  *     This file is part of the Linux TPE Suite and is made available under
  137.  *     the terms of the GNU General Public License, version 2, or at your
  138.  *     option, any later version, incorporated herein by reference.
  139.  *
  140.  *
  141.  * Revision history:
  142.  *
  143.  * Revision 0.01: Thu Apr  6 20:27:33 CEST 1998
  144.  *                Initial release for alpha testing.
  145.  * Revision 0.02: Sat Apr 11 21:58:06 CEST 1998
  146.  *          Minor cosmetic fixes.
  147.  *
  148.  */
  149.  
  150. static const char *version = "0.02";
  151.  
  152. #include <linux/tpe.h>
  153. #include <sys/types.h>
  154. #include <sys/stat.h>
  155. #include <sys/ioctl.h>
  156. #include <unistd.h>
  157. #include <string.h>
  158. #include <stdlib.h>
  159. #include <errno.h>
  160. #include <ctype.h>
  161. #include <stdio.h>
  162. #include <fcntl.h>
  163. #include <pwd.h>
  164.  
  165.  
  166. void banner(void)
  167. {
  168.     fprintf(stdout, "TPE Administrator, version %s\n", version); 
  169.     fprintf(stdout,    "Copyright (C) 1998 Krzysztof G. Baranowski. " 
  170.              "All rights reserved.\n");
  171.     fprintf(stdout, "Report bugs to <kgb@manjak.knm.org.pl>\n");
  172. }
  173.  
  174. void usage(const char *name)
  175. {
  176.     banner();
  177.     fprintf(stdout, "\nUsage:\n\t%s command\n", name);
  178.     fprintf(stdout, "\nCommands:\n"
  179.                         "  -a username\t\tadd username to the access list\n"
  180.                 "  -d username\t\tdelete username from the access list\n"
  181.                         "  -s\t\t\tshow access list\n"
  182.                         "  -h\t\t\tshow help\n"
  183.                         "  -v\t\t\tshow version\n");
  184. }
  185.  
  186. void print_pwd(int pid)
  187. {
  188.     struct passwd *pwd;
  189.     
  190.     pwd = getpwuid(pid);
  191.     if (pwd != NULL) 
  192.         fprintf(stdout, " %d\t%s\t  %s  \n", 
  193.                 pwd->pw_uid, pwd->pw_name, pwd->pw_gecos);
  194. }
  195.  
  196. void print_entries(int fd)
  197. {
  198.     int uid, i = 0;
  199.  
  200.     fprintf(stdout, "\n UID\tName\t  Gecos  \n");
  201.     fprintf(stdout, "-------------------------\n");
  202.     while (i < MAX_USERS) {
  203.         uid = ioctl(fd, TPE_SCGETENT, i);
  204.         if (uid > 0)
  205.             print_pwd(uid);
  206.         i++;
  207.     }
  208.     fprintf(stdout, "\n");
  209. }
  210.  
  211. int name2uid(const char *name)
  212. {
  213.     struct passwd *pwd;
  214.  
  215.     pwd = getpwnam(name);
  216.     if (pwd != NULL)
  217.         return pwd->pw_uid;
  218.     else {
  219.         fprintf(stderr, "%s: no such user.\n", name);
  220.         exit(EXIT_FAILURE);
  221.     }
  222. }
  223.  
  224. int add_entry(int fd, int uid)
  225. {
  226.     int ret;
  227.     errno = 0;
  228.     
  229.     ret = ioctl(fd, TPE_SCSETENT, uid);
  230.     if (ret < 0) {
  231.         fprintf(stderr, "Couldn't add entry: %s\n", strerror(errno));
  232.         exit(EXIT_FAILURE);
  233.     }
  234.     return 0;
  235. }
  236.  
  237. int del_entry(int fd, int uid)
  238. {
  239.     int ret;
  240.     errno = 0;
  241.  
  242.     ret = ioctl(fd, TPE_SCDELENT, uid);
  243.     if (ret < 0) {
  244.         fprintf(stderr, "Couldn't delete entry: %s\n", strerror(errno));
  245.         exit(EXIT_FAILURE);
  246.     }
  247.     return 0;
  248. }
  249.  
  250. int main(int argc, char **argv)
  251. {
  252.     const char *name = "/dev/tpe";
  253.     char *add_arg = NULL;
  254.     char *del_arg = NULL;
  255.     int fd, c;
  256.  
  257.         errno = 0;
  258.  
  259.     if (argc <= 1) {
  260.         fprintf(stderr, "%s: no command specified\n", argv[0]);
  261.         fprintf(stderr, "Try `%s -h' for more information\n", argv[0]);
  262.         exit(EXIT_FAILURE);
  263.     }
  264.  
  265.         fd = open(name, O_RDWR);
  266.         if (fd < 0) {
  267.                 fprintf(stderr, "Couldn't open file %s; %s\n", \
  268.                         name, strerror(errno));
  269.                 exit(EXIT_FAILURE);
  270.         }
  271.        
  272.     opterr = 0;
  273.  
  274.     while ((c = getopt(argc, argv, "a:d:svh")) != EOF)
  275.         switch (c)  {
  276.             case 'a':
  277.                 add_arg = optarg;
  278.                 add_entry(fd, name2uid(add_arg));
  279.                 break;
  280.             case 'd':
  281.                 del_arg = optarg;
  282.                 del_entry(fd, name2uid(del_arg));
  283.                 break;
  284.             case 's':
  285.                 print_entries(fd);
  286.                 break;
  287.             case 'v':
  288.                 banner();
  289.                 break;
  290.             case 'h':
  291.                 usage(argv[0]);
  292.                 break;
  293.             default :
  294.                 fprintf(stderr, "%s: illegal option\n", argv[0]);
  295.                 fprintf(stderr, "Try `%s -h' for more information\n", argv[0]);
  296.                 exit(EXIT_FAILURE);
  297.         }
  298.     exit(EXIT_SUCCESS);
  299. }
  300. <-->
  301. <++> EX/tpe-0.02/kernel-tpe-2.0.32.diff
  302. diff -urN linux-2.0.32/Documentation/Configure.help linux/Documentation/Configure.help
  303. --- linux-2.0.32/Documentation/Configure.help    Sat Sep  6 05:43:58 1997
  304. +++ linux/Documentation/Configure.help    Sat Apr 11 21:30:40 1998
  305. @@ -3338,6 +3338,27 @@
  306.    serial mice, modems and similar devices connecting to the standard
  307.    serial ports.
  308.  
  309. +Trusted path execution (EXPERIMENTAL)
  310. +CONFIG_TPE
  311. +  This option enables trusted path execution.  Binaries are considered
  312. +  `trusted` if they live in a root owned directory that is not group or
  313. +  world writable.  If an attempt is made to execute a program from a non
  314. +  trusted directory, it will simply not be allowed to run.  This is
  315. +  quite useful on a multi-user system where security is an issue.  Users
  316. +  will not be able to compile and execute arbitrary programs (read: evil)
  317. +  from their home directories, as these directories are not trusted.
  318. +  A list of non-root users allowed to run binaries can be modified
  319. +  by using program "tpadm". You should have received it with this
  320. +  patch. If not please visit http://www.knm.org.pl/prezes/index.html,
  321. +  mail the author - Krzysztof G. Baranowski <kgb@manjak.knm.org.pl>,
  322. +  or write it itself :-). This driver has been written as an enhancement
  323. +  to route's <route@infonexus.cm> original patch. (a check in do_execve() 
  324. +  in fs/exec.c for trusted directories, ie. root owned and not group/world
  325. +  writable). This option is useless on a single user machine.
  326. +  Logging of trusted path execution violation is configurable via /proc
  327. +  filesystem and turned off by default, to turn it on run you must run:
  328. +  "echo 1 > /proc/sys/kernel/tpe". To turn it off: "echo 0 > /proc/sys/..."
  329. +
  330.  Digiboard PC/Xx Support
  331.  CONFIG_DIGI
  332.    This is a driver for the Digiboard PC/Xe, PC/Xi, and PC/Xeve cards
  333. diff -urN linux-2.0.32/drivers/char/Config.in linux/drivers/char/Config.in
  334. --- linux-2.0.32/drivers/char/Config.in    Tue Aug 12 22:06:54 1997
  335. +++ linux/drivers/char/Config.in    Sat Apr 11 21:30:53 1998
  336. @@ -5,6 +5,9 @@
  337.  comment 'Character devices'
  338.  
  339.  tristate 'Standard/generic serial support' CONFIG_SERIAL
  340. +if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
  341. +  bool 'Trusted Path Execution (EXPERIMENTAL)' CONFIG_TPE
  342. +fi
  343.  bool 'Digiboard PC/Xx Support' CONFIG_DIGI
  344.  tristate 'Cyclades async mux support' CONFIG_CYCLADES
  345.  bool 'Stallion multiport serial support' CONFIG_STALDRV
  346. diff -urN linux-2.0.32/drivers/char/Makefile linux/drivers/char/Makefile
  347. --- linux-2.0.32/drivers/char/Makefile    Tue Aug 12 22:06:54 1997
  348. +++ linux/drivers/char/Makefile    Thu Apr  9 15:34:46 1998
  349. @@ -34,6 +34,10 @@
  350.    endif
  351.  endif
  352.  
  353. +ifeq ($(CONFIG_TPE),y)
  354. +L_OBJS += tpe.o
  355. +endif
  356. +
  357.  ifndef CONFIG_SUN_KEYBOARD
  358.  L_OBJS += keyboard.o defkeymap.o
  359.  endif
  360. diff -urN linux-2.0.32/drivers/char/tpe.c linux/drivers/char/tpe.c
  361. --- linux-2.0.32/drivers/char/tpe.c    Thu Jan  1 01:00:00 1970
  362. +++ linux/drivers/char/tpe.c    Sat Apr 11 22:06:36 1998
  363. @@ -0,0 +1,185 @@
  364. +/*
  365. + *     tpe.c - tpe driver
  366. + *
  367. + *    Copyright (C) 1998 Krzysztof G. Baranowski. All rights reserved.
  368. + *
  369. + *     This file is part of the Linux TPE Suite and is made available under
  370. + *     the terms of the GNU General Public License, version 2, or at your
  371. + *    option, any later version, incorporated herein by reference.
  372. + *
  373. + *
  374. + * Revision history:
  375. + *
  376. + * Revision 0.01: Thu Apr  6 18:31:55 CEST 1998
  377. + *                Initial release for alpha testing.
  378. + * Revision 0.02: Sat Apr 11 21:32:33 CEST 1998
  379. + *          Replaced CONFIG_TPE_LOG with sysctl option.
  380. + *
  381. + */
  382. +
  383. +static const char *version = "0.02";
  384. +
  385. +#include <linux/version.h>
  386. +#include <linux/module.h>
  387. +#include <linux/kernel.h>
  388. +#include <linux/sched.h>
  389. +#include <linux/config.h>
  390. +#include <linux/tpe.h>
  391. +#include <linux/mm.h>
  392. +#include <linux/fs.h>
  393. +
  394. +static const char *tpe_dev = "tpe";
  395. +static unsigned int tpe_major = 40;
  396. +static int tpe_users[MAX_USERS];
  397. +int tpe_log = 0;  /* sysctl boolean */
  398. +
  399. +#if 0
  400. +static void print_report(const char *info)
  401. +{
  402. +        int i = 0;
  403. +
  404. +        printk("Report: %s\n", info);
  405. +        while (i < MAX_USERS) {
  406. +                printk("tpe_users[%d] = %d\n", i, tpe_users[i]);
  407. +                i++;
  408. +        }
  409. +}
  410. +#endif
  411. +
  412. +static int is_on_list(int uid)
  413. +{
  414. +        int i;
  415. +
  416. +    for (i = 0; i < MAX_USERS; i++) {
  417. +                if (tpe_users[i] == uid)
  418. +                        return 0;
  419. +        }
  420. +        return -1;
  421. +}
  422. +
  423. +int tpe_verify(unsigned short uid, struct inode *d_ino)
  424. +{
  425. +    if (((d_ino->i_mode & (S_IWGRP | S_IWOTH)) == 0) && (d_ino->i_uid == 0))
  426. +         return 0;
  427. +    if ((is_on_list(uid) == 0) &&  (d_ino->i_uid == uid)  && 
  428. +        (d_ino->i_mode & (S_IWGRP | S_IWOTH)) == 0)
  429. +        return 0;
  430. +
  431. +    if (tpe_log)
  432. +        security_alert("Trusted path execution violation");
  433. +    return -1;
  434. +}
  435. +
  436. +static int tpe_find_entry(int uid)
  437. +{
  438. +        int i = 0;
  439. +
  440. +        while (tpe_users[i] != uid && i < MAX_USERS)
  441. +                i++;
  442. +    if (i >= MAX_USERS)
  443. +        return -1;
  444. +    else
  445. +            return i;
  446. +}
  447. +
  448. +static void tpe_revalidate(void)
  449. +{
  450. +        int temp[MAX_USERS];
  451. +        int i, j = 0;
  452. +
  453. +        memset(temp, 0, sizeof(temp));
  454. +        for (i = 0; i < MAX_USERS; i++) {
  455. +                if (tpe_users[i] != 0) {
  456. +                        temp[j] = tpe_users[i];
  457. +                        j++;
  458. +        }
  459. +    }
  460. +        memset(tpe_users, 0, sizeof(tpe_users));
  461. +        memcpy(tpe_users, temp, sizeof(temp));
  462. +}
  463. +
  464. +static int add_entry(int uid)
  465. +{
  466. +        int i;
  467. +
  468. +        if (uid <= 0)
  469. +                return -EBADF;
  470. +        if (!is_on_list(uid))
  471. +                return -EEXIST;
  472. +        if ((i = tpe_find_entry(0)) != -1) {
  473. +                tpe_users[i] = uid;
  474. +            tpe_revalidate();
  475. +            return 0;
  476. +    } else
  477. +        return -ENOSPC;
  478. +}
  479. +
  480. +static int del_entry(int uid)
  481. +{
  482. +        int i;
  483. +
  484. +        if (uid <= 0)
  485. +                return -EBADF;
  486. +        if (is_on_list(uid))
  487. +                return -EBADF;
  488. +        i = tpe_find_entry(uid);
  489. +        tpe_users[i] = 0;
  490. +        tpe_revalidate();
  491. +        return 0;
  492. +}
  493. +
  494. +static int tpe_ioctl(struct inode *inode, struct file *file,
  495. +                     unsigned int cmd, unsigned long arg)
  496. +{
  497. +        int argc = (int) arg;
  498. +        int retval;
  499. +
  500. +    if (!suser())
  501. +        return -EPERM;
  502. +        switch (cmd) {
  503. +                case TPE_SCSETENT:
  504. +                        retval = add_entry(argc);
  505. +            return retval;
  506. +                case TPE_SCDELENT:
  507. +                        retval = del_entry(argc);
  508. +            return retval;
  509. +        case TPE_SCGETENT:
  510. +            return tpe_users[argc];
  511. +                default:
  512. +                        return -EINVAL;
  513. +        }
  514. +}
  515. +
  516. +static int tpe_open(struct inode *inode, struct file *file)
  517. +{
  518. +    return 0;
  519. +}
  520. +
  521. +static void tpe_close(struct inode *inode, struct file *file)
  522. +{
  523. +    /* dummy */
  524. +}
  525. +
  526. +static struct file_operations tpe_fops = {
  527. +    NULL,         /* llseek */
  528. +    NULL,        /* read */
  529. +    NULL,        /* write */
  530. +    NULL,        /* readdir */
  531. +    NULL,         /* select */
  532. +    tpe_ioctl,    /* ioctl*/
  533. +    NULL,        /* mmap */
  534. +    tpe_open,    /* open */
  535. +    tpe_close,     /* release */
  536. +};
  537. +
  538. +int tpe_init(void)
  539. +{
  540. +    int result;
  541. +
  542. +        tpe_revalidate();
  543. +    if ((result = register_chrdev(tpe_major, tpe_dev, &tpe_fops)) != 0)
  544. +        return result;
  545. +    printk(KERN_INFO "TPE %s subsystem initialized... "
  546. +                      "(C) 1998 Krzysztof G. Baranowski\n", version);
  547. +    return 0;
  548. +}
  549. diff -urN linux-2.0.32/drivers/char/tty_io.c linux/drivers/char/tty_io.c
  550. --- linux-2.0.32/drivers/char/tty_io.c    Tue Sep 16 18:36:49 1997
  551. +++ linux/drivers/char/tty_io.c    Thu Apr  9 15:34:46 1998
  552. @@ -2030,6 +2030,9 @@
  553.  #ifdef CONFIG_SERIAL
  554.      rs_init();
  555.  #endif
  556. +#ifdef CONFIG_TPE
  557. +    tpe_init();
  558. +#endif
  559.  #ifdef CONFIG_SCC
  560.      scc_init();
  561.  #endif
  562. diff -urN linux-2.0.32/fs/exec.c linux/fs/exec.c
  563. --- linux-2.0.32/fs/exec.c    Fri Nov  7 18:57:30 1997
  564. +++ linux/fs/exec.c    Fri Apr 10 14:02:02 1998
  565. @@ -47,6 +47,11 @@
  566.  #ifdef CONFIG_KERNELD
  567.  #include <linux/kerneld.h>
  568.  #endif
  569. +#ifdef CONFIG_TPE
  570. +extern int tpe_verify(unsigned short uid, struct inode *d_ino);
  571. +extern int dir_namei(const char *pathname, int *namelen, const char **name,
  572. +                     struct inode *base, struct inode **res_inode);
  573. +#endif
  574.  
  575.  asmlinkage int sys_exit(int exit_code);
  576.  asmlinkage int sys_brk(unsigned long);
  577. @@ -652,12 +657,29 @@
  578.  int do_execve(char * filename, char ** argv, char ** envp, struct pt_regs * regs)
  579.  {
  580.      struct linux_binprm bprm;
  581. +        struct inode *dir;
  582. +        const char *basename;
  583. +        int namelen;
  584. +
  585.      int retval;
  586.      int i;
  587.  
  588.      bprm.p = PAGE_SIZE*MAX_ARG_PAGES-sizeof(void *);
  589.      for (i=0 ; i<MAX_ARG_PAGES ; i++)    /* clear page-table */
  590.          bprm.page[i] = 0;
  591. +
  592. +#ifdef CONFIG_TPE
  593. +    /* Check to make sure the path is trusted.  If the directory is root
  594. +     * owned and not group/world writable, it's trusted.  Otherwise,
  595. +     * return -EACCES and optionally log it
  596. +     */
  597. +    if (!suser()) {
  598. +        dir_namei(filename, &namelen, &basename, NULL, &dir);
  599. +        if (tpe_verify(current->uid, dir))
  600. +            return -EACCES;
  601. +    }
  602. +#endif /* CONFIG_TPE */
  603. +
  604.      retval = open_namei(filename, 0, 0, &bprm.inode, NULL);
  605.      if (retval)
  606.          return retval;
  607. diff -urN linux-2.0.32/fs/namei.c linux/fs/namei.c
  608. --- linux-2.0.32/fs/namei.c    Sun Aug 17 01:23:19 1997
  609. +++ linux/fs/namei.c    Thu Apr  9 15:34:46 1998
  610. @@ -216,8 +216,13 @@
  611.   * dir_namei() returns the inode of the directory of the
  612.   * specified name, and the name within that directory.
  613.   */
  614. +#ifdef CONFIG_TPE
  615. +int dir_namei(const char *pathname, int *namelen, const char **name,
  616. +                     struct inode * base, struct inode **res_inode)
  617. +#else
  618.  static int dir_namei(const char *pathname, int *namelen, const char **name,
  619.                       struct inode * base, struct inode **res_inode)
  620. +#endif /* CONFIG_TPE */
  621.  {
  622.      char c;
  623.      const char * thisname;
  624. diff -urN linux-2.0.32/include/linux/sysctl.h linux/include/linux/sysctl.h
  625. --- linux-2.0.32/include/linux/sysctl.h    Tue Aug 12 23:06:35 1997
  626. +++ linux/include/linux/sysctl.h    Sat Apr 11 22:04:13 1998
  627. @@ -61,6 +61,7 @@
  628.  #define KERN_NFSRADDRS    18    /* NFS root addresses */
  629.  #define KERN_JAVA_INTERPRETER 19 /* path to Java(tm) interpreter */
  630.  #define KERN_JAVA_APPLETVIEWER 20 /* path to Java(tm) appletviewer */
  631. +#define KERN_TPE 21 /* TPE logging */
  632.  
  633.  /* CTL_VM names: */
  634.  #define VM_SWAPCTL    1    /* struct: Set vm swapping control */
  635. diff -urN linux-2.0.32/include/linux/tpe.h linux/include/linux/tpe.h
  636. --- linux-2.0.32/include/linux/tpe.h    Thu Jan  1 01:00:00 1970
  637. +++ linux/include/linux/tpe.h    Thu Apr  9 15:34:46 1998
  638. @@ -0,0 +1,47 @@
  639. +/*
  640. + *     tpe.h - misc common stuff
  641. + *
  642. + *    Copyright (C) 1998 Krzysztof G. Baranowski. All rights reserved.
  643. + *
  644. + *     This file is part of the Linux TPE Suite and is made available under
  645. + *     the terms of the GNU General Public License, version 2, or at your
  646. + *    option, any later version, incorporated herein by reference.
  647. + *
  648. + */
  649. +
  650. +#ifndef __TPE_H__
  651. +#define __TPE_H__
  652. +
  653. +#ifdef __KERNEL__
  654. +/* Taken from Solar Designers' <solar@false.com> non executable stack patch */
  655. +#define security_alert(msg) { \
  656. +       static unsigned long warning_time = 0, no_flood_yet = 0; \
  657. +\
  658. +/* Make sure at least one minute passed since the last warning logged */ \
  659. +       if (!warning_time || jiffies - warning_time > 60 * HZ) { \
  660. +               warning_time = jiffies; no_flood_yet = 1; \
  661. +               printk( \
  662. +                       KERN_ALERT \
  663. +                       "Possible " msg " exploit attempt:\n" \
  664. +                       KERN_ALERT \
  665. +                       "Process %s (pid %d, uid %d, euid %d).\n", \
  666. +                       current->comm, current->pid, \
  667. +                       current->uid, current->euid); \
  668. +       } else if (no_flood_yet) { \
  669. +               warning_time = jiffies; no_flood_yet = 0; \
  670. +               printk( \
  671. +                       KERN_ALERT \
  672. +                       "More possible " msg " exploit attempts follow.\n"); \
  673. +       } \
  674. +}
  675. +#endif /* __KERNEL__ */
  676. +
  677. +/* size of tpe_users array */
  678. +#define MAX_USERS    32
  679. +
  680. +/* ioctl */
  681. +#define TPE_SCSETENT    0x3137
  682. +#define TPE_SCDELENT    0x3138
  683. +#define TPE_SCGETENT    0x3139
  684. +
  685. +#endif /* __TPE_H__ */
  686. diff -urN linux-2.0.32/include/linux/tty.h linux/include/linux/tty.h
  687. --- linux-2.0.32/include/linux/tty.h    Tue Nov 18 20:46:44 1997
  688. +++ linux/include/linux/tty.h    Sat Apr 11 21:45:20 1998
  689. @@ -283,6 +283,7 @@
  690.  extern unsigned long con_init(unsigned long);
  691.  
  692.  extern int rs_init(void);
  693. +extern int tpe_init(void);
  694.  extern int lp_init(void);
  695.  extern int pty_init(void);
  696.  extern int tty_init(void);
  697. diff -urN linux-2.0.32/kernel/sysctl.c linux/kernel/sysctl.c
  698. --- linux-2.0.32/kernel/sysctl.c    Thu Aug 14 00:02:42 1997
  699. +++ linux/kernel/sysctl.c    Sat Apr 11 21:40:03 1998
  700. @@ -26,6 +26,9 @@
  701.  /* External variables not in a header file. */
  702.  extern int panic_timeout;
  703.  
  704. +#ifdef CONFIG_TPE
  705. +extern int tpe_log;
  706. +#endif
  707.  
  708.  #ifdef CONFIG_ROOT_NFS
  709.  #include <linux/nfs_fs.h>
  710. @@ -147,6 +150,10 @@
  711.       64, 0644, NULL, &proc_dostring, &sysctl_string },
  712.      {KERN_JAVA_APPLETVIEWER, "java-appletviewer", binfmt_java_appletviewer,
  713.       64, 0644, NULL, &proc_dostring, &sysctl_string },
  714. +#endif
  715. +#ifdef CONFIG_TPE
  716. +    {KERN_TPE, "tpe", &tpe_log, sizeof(int),
  717. +     0644, NULL, &proc_dointvec},
  718.  #endif
  719.      {0}
  720. };
  721. <-->
  722.  
  723. ----[  EOF
  724.  
  725.